<template>
    <div>
        <!--<trial-form :form="form.trailList[0]" v-if="form.trailList.length == 1"></trial-form>-->

        <el-collapse class="collapseList" v-model="activeNames" style="margin-left: 5%" accordion>
            <div v-for="trial in form.trialList">
                <el-collapse-item :title="trial.creditNature" :name="trial.creditNature">
                    <trial-form :form="trial"></trial-form>
                </el-collapse-item>
            </div>
        </el-collapse>

        <el-form ref="form" :model="form" label-width="150px" :label-position="labelPosition" style="margin-left:5%">
            <el-form-item label="审核说明 :">
                <span>{{form.checkedNote}}</span>
            </el-form-item>
        </el-form>


        <div v-show="showTwoButton">
            <el-button @click.native="toDissent" style="margin-right: 10%;margin-left: 20%">提起异议</el-button>
            <el-button type="primary" @click.native="dialogConfirm=true" style="margin-left: 10%">确 认</el-button>

            <el-dialog title="" :visible.sync="dialogConfirm" width="80%">
                <span style="text-align: center;size: 18px">是否确认提交</span>
                <span slot="footer" class="dialog-footer">
                     <el-button @click="dialogConfirm = false" style="margin-right: 20%">取 消</el-button>
                     <el-button type="primary" @click="confirm" style="margin-left: 20%">确 定</el-button>
                 </span>
            </el-dialog>
        </div>

        <div v-show="showReplenishButton">
            <el-button @click.native="toBasics" style="margin-left: 5%">补正材料</el-button>
        </div>

        <span style="margin-top: 10%; width: 100%;color: red; text-align: center">{{form.specialNote}}</span>
        <!--<div class="list" v-if="showDissent">
            <el-form ref="form" :model="form" label-width="150px" :label-position="labelPosition">
                <el-form-item label="异议说明 :">
                    <span>{{form.declareNote}}</span>
                </el-form-item>
                <el-form-item label="异议文件 :">
                </el-form-item>
            </el-form>
            <el-table
                    :data="fileList"
                    @cell-click="downloadFile"
                    border
                    style="width: 100%">
                <el-table-column
                        prop="name"
                        label="材料">
                </el-table-column>
                <el-table-column
                        prop="updateDate"
                        label="上传时间"
                        width="105px">
                </el-table-column>
            </el-table>
        </div>-->
    </div>

</template>

<script>
    import TrialForm from './trial-form.vue'
    import util from 'assets/js/util.js'
    import conf from 'assets/js/conf.js'

    export default {
        data() {
            return {
                checkedNote: '',
                dialogConfirm: false,
                activeNames: [],
                ccdList: [],
                labelPosition: 'left',
            }
        },
        props: [
            'showReplenishButton',
            'showTwoButton',
            'form',
        ],
        mounted: function () {
            this.id = util.getUrlParam(document.location.href, 'id');

            /*if (!this.showButton) {
                const _self = this;
                util.ajax({
                    url: `/file/getFileList`,
                    params: {ids: this.form.declareFileids},
                    success: function (data) {
                        data.message.forEach(_file => _self.fileList.push({
                            updateDate: util.formatDate(_file.updateDate),
                            name: '异议文件 ' + (_self.fileList.length + 1),
                            id: _file.id
                        }))
                    },
                });
            }*/
        },
        methods: {
            toBasics: function () {
                window.location.href = '../register/register-credit.html?' + 'id=' + util.getUrlParam(document.location.href, 'id') + "&type=update";
            },
            toDissent: function () {
                window.location.href = '../credit/dissent.html?' + 'creditId=' + util.getUrlParam(document.location.href, 'id')
                /*  + 'caseId=' + this.caseId
                   + '&&creditorId=' + this.creditorId

                   + '&&ids=' + (this.form.declaerFileids);*/
            },
            confirm: function () {
                const _self = this;

                util.ajax({
                    url: `/credit/sure`,
                    params: {creditId: util.getUrlParam(document.location.href, 'id')},
                    success: function (data) {
                        _self.$message({
                            message: '确认成功!',
                            center: true
                        });
                        //window.location.href = '../index/index.html?';
                        window.location.href = '../creditor/creditor.html?';
                    },
                });

            },
            downloadFile: function (row, column, cell, event) {
                window.open(conf.baseUrl + '/file/get/' + row.id + '?type=1')
            },
        },
        components: {
            TrialForm
        }
    }
</script>

<style scoped>
    .el-form-item span {
        float: left;
        margin-right: 20%;
    }

    .recheck-button {
        width: 100%;
        text-align: center;
        margin-top: 6%
    }

    .el-form-item {
        margin-bottom: 10px;
    }

    .list {
        width: 90%;
        margin-left: 5%;
    }
</style>
